﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MagicArenaXNA.GameObject.Spells.concrete;
using Networking;
using MagicArenaFramework.GameObject.Components;
using MagicArenaXNA.GameObject.Spells.factory.objects;
using Microsoft.Xna.Framework;
using MagicArenaXNA.World;
using BEPUphysics;
using MagicArenaXNA.Games;

namespace MagicArenaXNA.GameObject.Spells.factory
{
    class BasicSpellFactory : GoCompositeMultiple, ISpellFactory
    {
        SimpleGameClient Client;
        Space Space;
        BepuGame Game;
        Vector3 spellOffset = new Vector3(0f, 0f, 5f);

        public BasicSpellFactory(SimpleGameClient client, BepuWorld world, BepuGame game)
        {
            Client = client;
            Space = world.Space;
            Game = game;
        }

        public void CreateSpell(SpellBase spell, BEPUphysics.Entities.Entity source, BEPUphysics.Entities.Entity target)
        {
            UInt64 id = spell.SpellId;
            Vector3 spellPos = source.Position;
            Quaternion spellRot = source.Orientation;
            spellPos += Vector3.Transform(spellOffset, Matrix.CreateFromQuaternion(spellRot));
            GoComponent spellComp;
            switch (id)
            {
                case 0:
                    spellComp = new FireballOne(spellPos, target, Space, Game);
                    this.AddChild(spellComp);
                    spellComp.isActive = true;
                    break;

                default:
                    throw new NotImplementedException();
            }
        }
    }
}
